package com.example.offer.no0005.impl;

import org.springframework.util.StringUtils;

import com.example.offer.no0005.Solution;

/**
 * @author yumuhui <yumuhui@kuaishou.com>
 * Created on 2021-05-13
 */
public class SolutionImpl implements Solution {
    @Override
    public String replaceSpace(String s) {
        if (StringUtils.isEmpty(s)) {
            return "";
        }
        StringBuilder sb = new StringBuilder();
        for (int i=0; i<s.length(); i++) {
            char c = s.charAt(i);
            if (c == ' ') {
                sb.append("%20");
            } else {
                sb.append(c);
            }
        }
        return sb.toString();
    }
}
